<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <script src="../../js/load.js"></script>
</head>

<body>
<div class="layui-fluid">
    <div class="flexrow">
        <div class="layui-panel list-container">
            <table class="layui-table" lay-data="{id: 'datagrid',height:'full'}" lay-filter="datagrid">
                <thead>
                <tr>
                    <th lay-data="{field:'versionName',width:250}">版本名称</th>
                    <th lay-data="{fixed: 'right',width:100, align:'center', toolbar: '#action'}">强制保留</th>
                    <th lay-data="{field:'versionRemark'}">备注</th>
                    <th lay-data="{fixed: 'right', width:260, align:'center', toolbar: '#op'}">操作</th>
                </tr>
                </thead>
            </table>
        </div>
    </div>
</div>
</body>
<script type="text/html" id="action">
    {{#  if(d.forceKeep=='1'){ }}
    <span style="color:green">是</span>
    {{#  } else { }}
    <span style="color:red">否</span>
    {{#  } }}
</script>
<script type="text/html" id="op">
    <button class="layui-btn layui-btn-sm" lay-event="HandleRecover"><i
            class="layui-icon layui-icon-auz layui-font-12"></i>还原
    </button>
    <button class="layui-btn layui-btn-sm" lay-event="HandleEdit"><i
            class="layui-icon layui-icon-edit layui-font-12"></i>编辑
    </button>
    <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="HandleDelete"><i
            class="layui-icon layui-icon-delete layui-font-12"></i>删除
    </button>
</script>
</html>
<script>
    $(function () {
        layui.use('laytpl', function () {
        })
        BindTableData();
    })

    function BindTableData() {
        var param = {
            projectID: GetUrlParam("projectID")
        }
        BindTable("datagrid", "api/depolyversion/list", param, function (result) {

        }, false);
    }

    function HandleRecover(RowData){
         OpenConfirm('确认还原此版本？', function () {
            var param = {
                versionID: RowData.versionID,
            }
            HttpPost(JSON.stringify(param), 'api/depolyversion/recover', function (result) {
                if (result.code == 0) {
                    OpenSuccessMessage("还原成功")
                } else {
                    OpenFail(result.msg);
                }
            })
        })
    }

    function HandleEdit(RowData) {
       OpenDialog('编辑版本信息', 'pages/depolyversion/version_edit.html?versionID=' +RowData.versionID, 800, 600 , function () {
            BindTableData();
        })
    }

    function HandleDelete(RowData) {
        OpenConfirm('确认删除？', function () {
            var param = {
                versionID: RowData.versionID,
            }
            HttpPost(JSON.stringify(param), 'api/depolyversion/delete', function (result) {
                if (result.code == 0) {
                    OpenSuccessMessage("删除成功")
                    BindTableData();
                } else {
                    OpenFail(result.msg);
                }
            })
        })
    }







</script>